// import proFetch from "../../../../../public/functions/project-fetch";
import {hrAjax as ajax} from 'src/hrpub/common/utils/utils';

import setButtonStatus from "../../../container/functions/setButtonStatus";
import handlePK from "../../../container/functions/handlePK";
import handleAllpks from "../../../container/functions/handleAllpks";
import {toast} from 'nc-lightapp-front';

export default function saveDisputedInfo(callback) {
    const {orgVal,  form, updateState, cardPagination, button} = this.props;

    const flag = form.isCheckNow('detail');
    if (!flag) {
        return;
    }

    let postData = {
        model: form.getAllFormValue('detail'),
        pk_org: orgVal && orgVal.refpk
    };

    return ajax({
        url: '/nccloud/hrcm/disputed/DisputedSaveAction.do',
        body: postData,
    })
        .then((res) => {
            if (res.success) {
                const pk_workdispute = res.data.pk_workdispute;
                setButtonStatus.call(this, 'afterSave');
                toast({
                    color: 'success',
                    content: this.props.json['cm6011-000005']/* 国际化处理： 保存成功*/
                });
                if (!postData.model.rows[0].values.pk_workdispute.value){
                    handlePK.add(pk_workdispute);
                    handleAllpks.add(pk_workdispute);
                }
                if( !!res.data ){
                    button.setButtonDisabled({
                        edit: false,
                        delete: false
                    })
                }
                callback&&callback();
            }
        });

}
